package com.bpr.webservice.domain;

import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Transient;

import org.springframework.security.core.GrantedAuthority;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
public class Users {

    @Id
    @SequenceGenerator(name="users_userid",sequenceName="userid_seq", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="users_userid")
    @Basic(optional = false)
    @Column(name = "userid")
    private Long userid;
    @Basic(optional = false)
    @Column(name = "username")
    private String username;
    @Basic(optional = false)
    @Column(name = "passwd")
    private String passwd;
    @Basic(optional = false)
    @Column(name = "enabled")
    private char enabled;
//    @JsonIgnore
    @JoinColumn(name = "usergroupid", referencedColumnName = "usergroupid")
    @ManyToOne(fetch = FetchType.LAZY)
    private Usergroups usergroupid;
//    @JsonIgnore
    @OneToMany(mappedBy = "userid", fetch = FetchType.LAZY)
    private List<Menuaccess> menuaccessList;
    @Transient
//    @JsonIgnore
    private List<GrantedAuthority> grantedAuthorities;
	public Users() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Long getUserid() {
		return userid;
	}
	public void setUserid(Long userid) {
		this.userid = userid;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPasswd() {
		return passwd;
	}
	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	public char getEnabled() {
		return enabled;
	}
	public void setEnabled(char enabled) {
		this.enabled = enabled;
	}
	public Usergroups getUsergroupid() {
		return usergroupid;
	}
	public void setUsergroupid(Usergroups usergroupid) {
		this.usergroupid = usergroupid;
	}
	public List<Menuaccess> getMenuaccessList() {
		return menuaccessList;
	}
	public void setMenuaccessList(List<Menuaccess> menuaccessList) {
		this.menuaccessList = menuaccessList;
	}
	public List<GrantedAuthority> getGrantedAuthorities() {
		return grantedAuthorities;
	}
	public void setGrantedAuthorities(List<GrantedAuthority> grantedAuthorities) {
		this.grantedAuthorities = grantedAuthorities;
	}
	@Override
	public String toString() {
		return "Users [userid=" + userid + ", username=" + username
				+ ", passwd=" + passwd + ", enabled=" + enabled
				+ ", usergroupid=" + usergroupid + ", menuaccessList="
				+ menuaccessList + ", grantedAuthorities=" + grantedAuthorities
				+ "]";
	}

    
}
